/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = apm4lua_core.c                                     */
/*  NOTE      =                                                    */
/*  DATE      = 2015/03/09 by yaohl                                */
/*******************************************************************/

#include <stdio.h>

#if defined(FRLINUX4) || defined(FRLINUX5)
    extern "C"{
    #include <lua.h>
    }
#else
    #ifdef LIB_APM_LUAJIT
    #include <luajit-2.0/lua.hpp>
    #else
    #include <lua.hpp>
    #endif
#endif

#include "apm4lua_mem.h"
#include "apm4lua_report.h"

//内存相关函数
static const struct luaL_Reg lib_mem[] =
{
    {"set",     memstat_set},

    {NULL,NULL}
};

//report相关函数
static const struct luaL_Reg lib_report[] =
{
    {"get_messageType", luaReport_get_messageType},
    {"get_l4proto",     luaReport_get_l4proto},
    {"get_l7proto",     luaReport_get_l7proto},
    {"set_l7proto",     luaReport_set_l7proto},

    {"get_srcIp",       luaReport_get_srcIp},
    {"get_srcPort",     luaReport_get_srcPort},
    {"get_dstIp",       luaReport_get_dstIp},
    {"get_dstPort",     luaReport_get_dstPort},

    {"set_srcIp",       luaReport_set_srcIp},
    {"set_srcPort",     luaReport_set_srcPort},
    {"set_dstIp",       luaReport_set_dstIp},
    {"set_dstPort",     luaReport_set_dstPort},

    {"get_fieldSize",   luaReport_get_fieldSize},
    {"get_existsField", luaReport_get_existsField},

    {"get_field",       luaReport_get_field},
    {"add_fieldStr",    luaReport_add_fieldStr},
    {"add_fieldLong",   luaReport_add_fieldLong},
    {"add_fieldDouble", luaReport_add_fieldDouble},

    {"del_fieldAll",    luaReport_del_fieldAll},
    {"del_fieldIndex",  luaReport_del_fieldIndex},

    {"dumpField",       luaReport_dumpField},

    {"getmicrosecond",  luaReport_get_microsecond},
    {"getmillisecond",  luaReport_get_millisecond},

    {"strToUTF8",       luaReport_str_to_utf8},

    {"PEMReadBIORSAPrivateKey", luaReport_PEM_read_bio_RSAPrivateKey},
    {"RSAPrivateDecrypt", luaReport_RSA_private_decrypt},

    {"AESCBCDecrypt",   luaReport_AES_cbc_encrypt},

    {NULL,NULL}
};

#ifdef __cplusplus
extern "C"
{
#endif


int luaopen_apm4lua(lua_State *L)
{
    luaL_register(L,"apm4mem",      lib_mem);
    luaL_register(L,"apm4report",   lib_report);

    return 1;
}

#ifdef __cplusplus
}
#endif


